# 数据处理层Model，实现数据读取，写入
import json
def read_data(jsonpath):
    with open(jsonpath,mode='r',encoding='utf-8')as f:
        data=json.load(f)
    return  data
def wirte_data(data_list,jsonpath):
    with open(jsonpath,mode='w',encoding='utf-8')as f:
        json.dump(data_list,f,ensure_ascii=False)

# if __name__ == '__main__':
#     jsonpath=r'book.json'
#     print(read_data(jsonpath))
#
#     user_list= [
#   {
#     "时间": "2021/8/21 09:00:00",
#     "项目": "工资 ",
#     "分类": "收入",
#     "金额": "20000"
#   },
#   {
#     "时间": "2021/8/21 09:00:00",
#     "项目": "聚餐",
#     "分类": "支出",
#     "金额": "-200"
#   }
# ]
#     wirte_data(user_list,jsonpath)